import pymongo

class Client:

    def __init__(self):
        self.myclient = pymongo.MongoClient()
        self.dblist = self.myclient.list_database_names()
    
    def _view_db(self):
        return self.dblist
    
    def _add_one(self, db:str, col:str, data:dict):
        mydb = self.myclient[db]
        mycol = mydb[col]
        return mycol.insert_one(data)
    
    def _delete_one(self, db:str, col:str, filter:dict):
        mydb = self.myclient[db]
        mycol = mydb[col]
        return mycol.delete_one(filter)
    
    def _edit_one(self, db:str, col:str, filter:dict, update:dict):
        mydb = self.myclient[db]
        mycol = mydb[col]
        return mycol.update_one(filter, update)
    
    def _find(self, db:str, col:str):
        mydb = self.myclient[db]
        mycol = mydb[col]
        return mycol.find()
